home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-11 | 1.6 KB | 65 lines | [TEXT/CWIE] |
- // =================================================================================
- // CProducerThread.cp ©1996 Metrowerks Inc. All rights reserved.
- // =================================================================================
-
- #include <LLink.h>
- #include <LSharedQueue.h>
-
- #include "LThermometerPane.h"
-
- #include "CProducerThread.h"
-
-
- // ---------------------------------------------------------------------------------
- // • CProducerThread
- // ---------------------------------------------------------------------------------
-
- CProducerThread::CProducerThread(
- LSharedQueue *inQueue,
- LThermometerPane *inProgressPane )
- : LThread( false ), mQueue( inQueue ), mProgressPane( inProgressPane )
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ~CProducerThread
- // ---------------------------------------------------------------------------------
-
- CProducerThread::~CProducerThread()
- {
- }
-
-
- // ---------------------------------------------------------------------------------
- // • Run
- // ---------------------------------------------------------------------------------
-
- void *
- CProducerThread::Run( void )
- {
- Int32 theMinValue;
- Int32 theValue;
-
- // Get the progress bar min value.
- theMinValue = mProgressPane->GetMinValue();
-
- // Produce as long as the progress bar isn't empty.
- while ( (theValue = mProgressPane->GetCurrentValue()) > theMinValue ) {
-
- // Put data in the shared queue.
- mQueue->NextPut( new LLink );
-
- // Decrement the progress bar value.
- mProgressPane->SetCurrentValue( theValue - 1 );
-
- // Yield so that other threads may get time.
- Yield();
-
- }
-
- Suspend();
-
- return nil;
- }
-